<!DOCTYPE html>
<!--
     SPDX-License-Identifier: CC-BY-SA-4.0
     SPDX-FileCopyrightText: 2020 seL4 Project a Series of LF Projects, LLC.
-->
<!-- Page last generated 2025-02-20 03:16:15 +0000 -->
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>libsel4vmmplatsupport_ioports | seL4 docs</title>

    <!-- Our stylesheet and theme stylesheet.  Contains bootstrap. -->
    <link rel="stylesheet" href="/assets/css/style.css" type="text/css">
    <!-- Font awesome -->
    <link href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
    <!-- Pygments syntax highlighting  -->
    <link rel="stylesheet" href="/assets/css/highlighting/trac.css" type="text/css">
    <link rel="icon" type="image/x-icon" href="/assets/favicon.ico"><script defer data-domain="docs.sel4.systems"
	    src="https://analytics.sel4.systems/js/script.js"></script></head>

  <body class="container-fluid">

    



<header>
  <ul class="row menu">
    <li class="col-xs-12 col-md-2" >
            <a href="https://sel4.systems" class="skip-icon">
              <img class="img-responsive" src="/assets/logo-text-white.svg" alt="seL4 logo" />
            </a>
    </li>
    <li class="col-xs-12 col-md-10 menu">
      <nav aria-label="Banner links">
        <h2><a href="/Resources" />Resources</h2>
        <h2><a href="/processes" />Contributing</a></h2>
        <h2><a href="/projects" />Projects</h2>
        <h2><a href="/Tutorials" />Tutorials</h2>
        <iframe title="DuckDuckGo search bar" src="https://duckduckgo.com/search.html?site=docs.sel4.systems&prefill=Search%20sel4.systems" style="overflow:hidden;margin-bottom:10px; padding:0;height:40px;float:right;border-width: 0px"></iframe>
      </nav>
    </li>
  </ul>
  <div class="clear"></div>
  
<div class="breadcrumbs bootstrap hidden-sm-down">
  <nav class="sel-breadcrumb" aria-label="Breadcrumb" >
    <ol class=" list-unstyled" vocab="http://schema.org/" typeof="BreadcrumbList">
      
      
        

        

        <li class="breadcrumb-item" property="itemListElement" typeof="ListItem">
            <a property="item" typeof="WebPage" href="/">
              <span property="name"><b>seL4 Docs</b></span>
            </a>
            <meta property="position" content="1" />
        </li>
      
        

        

        <li class="breadcrumb-item" property="itemListElement" typeof="ListItem">
            <a property="item" typeof="WebPage" href="/projects/">
              <span property="name"><b>Projects</b></span>
            </a>
            <meta property="position" content="2" />
        </li>
      
        

        

        <li class="breadcrumb-item" property="itemListElement" typeof="ListItem">
            <a property="item" typeof="WebPage" href="/projects/virtualization/">
              <span property="name"><b>Virtualisation on seL4</b></span>
            </a>
            <meta property="position" content="3" />
        </li>
      
        

        

        <li class="breadcrumb-item" property="itemListElement" typeof="ListItem">
            <a property="item" typeof="WebPage" href="/projects/virtualization/docs/">
              <span property="name"><b>libsel4vm & libsel4vmmplatsupport API documentation</b></span>
            </a>
            <meta property="position" content="4" />
        </li>
      
        

        
          <li class="breadcrumb-item" property="itemListElement" typeof="ListItem">
            <span property="name">libsel4vmmplatsupport_ioports</span>
            <meta property="position" content="5" /></li>
          
    </ol>
  </nav>
  <nav class="sel-version" aria-label="Current Versions">
    <ol class="list-unstyled">
      <li class="list-unstyled text-right" style="margin-left:auto; padding:0rem 0rem;">
        Current versions:</li>
      <li class="list-unstyled text-right">
      <a href="/releases/sel4/13.0.0"><b>seL4-13.0.0</b></a></li>
      <li class="list-unstyled text-right">
      <a href="/releases/microkit/1.4.1"><b>microkit-1.4.1</b></a></li>
      <li class="list-unstyled text-right">
      <a href="/releases/camkes/camkes-3.11.0"><b>camkes-3.11.0</b></a></li>
      <li class="list-unstyled text-right">
      <a href="/releases/capdl/0.3.0"><b>capDL-0.3.0</b></a></li>
      </ol>
  </nav>
  <div class='clear'></div>
</div>


</header>

    <main>
      <div class="row">
  <div class="hidden-xs col-sm-4 col-md-3 col-lg-2">
    


<div class="sidebar">















    <ul class="nav nav-sidebar">
  
    
    

    
        <li class="">
            <a class="" href="/projects/sel4/">seL4</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/l4v/">L4.verified</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/camkes/">CAmkES</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/capdl/">CapDL</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/elfloader/">Elfloader</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/buildsystem/">seL4 Buildsystem</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/user_libs/">user_libs</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/sel4runtime/">The seL4 run-time</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/sel4webserver/">seL4webserver</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/sel4-tutorials/">seL4 tutorials</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/sel4bench/">sel4bench</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/sel4test/">seL4Test</a>
        </li>
  
    
    

    
        <li class="active">
            <a class="" href="/projects/virtualization/">Virtualization</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/camkes-vm/">camkes-vm</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/dockerfiles/">Dockerfiles</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/docsite/">seL4 Documentation website</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/sel4_tools/">seL4_tools</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/microkit/">Microkit</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/hardware_hacks/">Hardware Hacks</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/rust/">Rust</a>
        </li>
  
    </ul>


</div>

  </div>
  <div class="content col-sm-8 col-md-6 col-lg-7 main">
    <!--
     Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)

     SPDX-License-Identifier: CC-BY-SA-4.0
-->

<h2 id="interface-ioportsh">Interface <code class="language-plaintext highlighter-rouge">ioports.h</code></h2>

<p>The ioports interface provides a useful abstraction for initialising, registering and handling ioport events
for a guest VM instance. This is independent from the x86 libsel4vm ioports interface. This interface is intended
to be more generic and architecture independent, useful for usecases that require ioports without architecture
support (virtio PCI).</p>

<h3 id="brief-content">Brief content:</h3>

<p><strong>Functions</strong>:</p>

<blockquote>
  <p><a href="#function-vmm_io_port_initio_list-ioport_alloc_addr"><code class="language-plaintext highlighter-rouge">vmm_io_port_init(io_list, ioport_alloc_addr)</code></a></p>
</blockquote>

<blockquote>
  <p><a href="#function-vmm_io_port_add_handlerio_list-ioport_range-ioport_interface-port_type"><code class="language-plaintext highlighter-rouge">vmm_io_port_add_handler(io_list, ioport_range, ioport_interface, port_type)</code></a></p>
</blockquote>

<blockquote>
  <p><a href="#function-emulate_io_handlerio_port-port_no-is_in-size-data"><code class="language-plaintext highlighter-rouge">emulate_io_handler(io_port, port_no, is_in, size, data)</code></a></p>
</blockquote>

<p><strong>Structs</strong>:</p>

<blockquote>
  <p><a href="#struct-ioport_range"><code class="language-plaintext highlighter-rouge">ioport_range</code></a></p>
</blockquote>

<blockquote>
  <p><a href="#struct-ioport_interface"><code class="language-plaintext highlighter-rouge">ioport_interface</code></a></p>
</blockquote>

<blockquote>
  <p><a href="#struct-ioport_entry"><code class="language-plaintext highlighter-rouge">ioport_entry</code></a></p>
</blockquote>

<blockquote>
  <p><a href="#struct-vmm_io_list"><code class="language-plaintext highlighter-rouge">vmm_io_list</code></a></p>
</blockquote>

<h2 id="functions">Functions</h2>

<p>The interface <code class="language-plaintext highlighter-rouge">ioports.h</code> defines the following functions.</p>

<h3 id="function-vmm_io_port_initio_list-ioport_alloc_addr">Function <code class="language-plaintext highlighter-rouge">vmm_io_port_init(io_list, ioport_alloc_addr)</code></h3>

<p>Initialize the io port list manager.
This is used when registering ioport handlers of type ‘IOPORT_FREE’</p>

<p><strong>Parameters:</strong></p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">io_list {vmm_io_port_list_t **}</code>: Pointer to io_port list handle. This will be allocated and initialised</li>
  <li><code class="language-plaintext highlighter-rouge">ioport_alloc_addr {uint16_t}</code>: Base ioport address we can safely bump allocate from (doesn’t conflict with other ioports).</li>
</ul>

<p><strong>Returns:</strong></p>

<ul>
  <li>0 for success, otherwise -1 for error</li>
</ul>

<p>Back to <a href="#module-ioportsh">interface description</a>.</p>

<h3 id="function-vmm_io_port_add_handlerio_list-ioport_range-ioport_interface-port_type">Function <code class="language-plaintext highlighter-rouge">vmm_io_port_add_handler(io_list, ioport_range, ioport_interface, port_type)</code></h3>

<p>Add an io port range for emulation</p>

<p><strong>Parameters:</strong></p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">io_list {vmm_io_port_list_t *}</code>: Handle to ioport list. This is where the new ioport handler will be appended to</li>
  <li><code class="language-plaintext highlighter-rouge">ioport_range {ioport_range_t}</code>: Range the ioport handler will emulate</li>
  <li><code class="language-plaintext highlighter-rouge">ioport_interface {ioport_interface_t}</code>: IOPort emulation interface</li>
  <li><code class="language-plaintext highlighter-rouge">port_type {ioport_type_t}</code>: The type of ioport being registered - IOPORT_FREE, IOPORT_ADDR</li>
</ul>

<p><strong>Returns:</strong></p>

<ul>
  <li>NULL for error, otherwise pointer to newly created ioport entry</li>
</ul>

<p>Back to <a href="#module-ioportsh">interface description</a>.</p>

<h3 id="function-emulate_io_handlerio_port-port_no-is_in-size-data">Function <code class="language-plaintext highlighter-rouge">emulate_io_handler(io_port, port_no, is_in, size, data)</code></h3>

<p>From a set of registered ioports, emulate an io instruction given a current ioport access.</p>

<p><strong>Parameters:</strong></p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">io_port {vmm_io_port_list_t *}</code>: List of registered ioports with in/out handlers</li>
  <li><code class="language-plaintext highlighter-rouge">port_no {unsigned int}</code>: IOPort address being accessed</li>
  <li><code class="language-plaintext highlighter-rouge">is_in {bool}</code>: True if we are performing an io in operation, otherwise False</li>
  <li><code class="language-plaintext highlighter-rouge">size {size_t}</code>: Size of io access</li>
  <li><code class="language-plaintext highlighter-rouge">data {unsigned int *}</code>: Pointer with the data being written if io-out op, otherwise will be populated with data from an io-in op</li>
</ul>

<p><strong>Returns:</strong></p>

<ul>
  <li>0 if handled, 1 if unhandled, otherwise -1 for error</li>
</ul>

<p>Back to <a href="#module-ioportsh">interface description</a>.</p>

<h2 id="structs">Structs</h2>

<p>The interface <code class="language-plaintext highlighter-rouge">ioports.h</code> defines the following structs.</p>

<h3 id="struct-ioport_range">Struct <code class="language-plaintext highlighter-rouge">ioport_range</code></h3>

<p>Range of ioport handler</p>

<p><strong>Elements:</strong></p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">start {uint16_t}</code>: Start address of ioport range</li>
  <li><code class="language-plaintext highlighter-rouge">end {uint16_t}</code>: End address of ioport range</li>
  <li><code class="language-plaintext highlighter-rouge">size {uint16_t}</code>: Size of ioport range</li>
</ul>

<p>Back to <a href="#module-ioportsh">interface description</a>.</p>

<h3 id="struct-ioport_interface">Struct <code class="language-plaintext highlighter-rouge">ioport_interface</code></h3>

<p>Datastructure used for ioport emulation, containing handlers for the ioport range</p>

<p><strong>Elements:</strong></p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">cookie {void *}</code>: User supplied cookie to pass onto handlers</li>
  <li><code class="language-plaintext highlighter-rouge">port_in {ioport_in_fn}</code>: IO in operation handler</li>
  <li><code class="language-plaintext highlighter-rouge">port_out {ioport_out_fn}</code>: IO out operation handler</li>
  <li><code class="language-plaintext highlighter-rouge">desc {const char *}</code>: IOPort description, useful for debugging</li>
</ul>

<p>Back to <a href="#module-ioportsh">interface description</a>.</p>

<h3 id="struct-ioport_entry">Struct <code class="language-plaintext highlighter-rouge">ioport_entry</code></h3>

<p>Datastructure used to present a registered ioport range</p>

<p><strong>Elements:</strong></p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">range {ioport_range_t}</code>: IO address range of ioport entry</li>
  <li><code class="language-plaintext highlighter-rouge">interface {ioport_interface_t}</code>: Emulation interface for ioport range</li>
</ul>

<p>Back to <a href="#module-ioportsh">interface description</a>.</p>

<h3 id="struct-vmm_io_list">Struct <code class="language-plaintext highlighter-rouge">vmm_io_list</code></h3>

<p>Parent datastructure used to maintain a list of registered ioports</p>

<p><strong>Elements:</strong></p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">num_ioports {int}</code>: Total number of registered ioports</li>
  <li><code class="language-plaintext highlighter-rouge">List {ioport_entry_t **}</code>: of registered ioport objects</li>
  <li><code class="language-plaintext highlighter-rouge">alloc_addr {uint16_t}</code>: Base ioport address we can safely bump allocate from, used when registering ioport handlers of type ‘IOPORT_FREE’</li>
</ul>

<p>Back to <a href="#module-ioportsh">interface description</a>.</p>

<p>Back to <a href="#">top</a>.</p>


  </div>







  
  
<div class="sidebar-toc hidden-xs hidden-sm col-md-3 col-lg-3">
  
    <ul class="section-nav">
    	<h2> Virtualization </h2> 
        <li>
          
          <a style="" class="" href="/projects/virtualization/">
            Documentation homepage
          </a>
        </li>

















    
        <h3>Repositories</h3>
    
        <li>
          <a class="" href="https://github.com/seL4proj/seL4_projects_libs">
            seL4_projects_libs
          </a>
        </li>









  







    </ul>

</div>


</div>

    </main>
    


<footer class="site-footer">

  <h2 class="footer-heading">seL4 docs</h2>

  <div class="footer-col-wrapper">

    <div class="col-md-2">
      



<ul class="social-media-list">
  <li><a href="https://github.com/sel4"><i class="fab fa-github"></i> <span class="username">sel4</span></a></li><li><a href="https://github.com/sel4proj"><i class="fab fa-github"></i> <span class="username">sel4proj</span></a></li>
</ul>

    </div>

    <div class="col-md-8">
      <ul class="list-unstyled">
        <li>
          This site is for displaying seL4 related documentation.  Pull requests are welcome.
        </li>
        
          <li>
            Site last updated: Fri Feb 7 10:17:38 2025 +1100 ee78c8857c
          </li>
          <li>
                Page last updated: 
          </li>
        
      </ul>
    </div>
    <div class="col-md-2">
<a href="https://github.com/seL4/docs/blob/master/projects/virtualization/docs/api/libsel4vmmplatsupport_ioports.md">View page on GitHub</a>
      <br />
      <a href="https://github.com/seL4/docs/edit/master/projects/virtualization/docs/api/libsel4vmmplatsupport_ioports.md">Edit page on GitHub</a>
      <br />
      <a href="/sitemap">Sitemap</a>
    </div>

  </div>

</footer>

  </body>
</html>
